function reducer(state, action) {
    return action.state
}

function useState(initState) {
    if (typeof initState === 'function') {
        initState = initState()
    }
    const [state, dispatch] = useReducer(reducer, initState)

    function setState(newState) {
        dispatch({
            type: 'update',
            data: newState
        })
    }

    return [state, setState]
}